package com.boot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boot.entity.Permission;
import com.boot.entity.RolePermssion;
import com.boot.mapper.PermissionMapper;
import com.boot.mapper.RolePermissionMapper;
import com.boot.service.PermissionService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper,Permission> implements PermissionService {

    private final PermissionMapper permissionMapper;

    private final RolePermissionMapper rolePermissionMapper;

    public void deletePermission(Long permissionId) {
        //String sql = "delete from sys_roles_permissions where permission_id=?";
        QueryWrapper<RolePermssion> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("permission_id",permissionId);
        rolePermissionMapper.delete(queryWrapper);

        permissionMapper.deleteById(permissionId);
    }
}
